local congjian = fk.CreateSkill {
  name = "lvshi__congjian",
}

Fk:loadTranslationTable{
  ["lvshi__congjian"] = "从谏",
  [":lvshi__congjian"] = "你可将一张武器牌当【调虎离山】使用；若你没有未调离的其他己方角色，你使用【杀】造成的伤害+1。",

  ["$lvshi__congjian1"] = "皆道明公善容人，为何营中尚有小人乎！",
  ["$lvshi__congjian2"] = "吾心昭昭，愿为公清君侧、除奸臣！",
}

local ls = require "packages/lvshi/utility"

local function hasmarksuffix(player, mark)
  for _, suffix in ipairs(MarkEnum.TempMarkSuffix) do
    if player:getMark(mark..suffix) > 0 then return true end
  end
  return false
end

congjian:addEffect("viewas", {
  pattern = "lvshi__lure_tiger",
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).sub_type == Card.SubtypeWeapon
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return nil end
    local card = Fk:cloneCard("lvshi__lure_tiger")
    card.skillName = congjian.name
    card:addSubcards(cards)
    return card
  end,
})

congjian:addEffect(fk.DamageCaused, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(congjian.name) and data.card and data.card.trueName == "slash"
    and #table.filter(player.room:getOtherPlayers(player), function (p)
      return ls.isFriend(player, p) and not hasmarksuffix(p, "@@remove_player")
    end) == 0
  end,
  on_refresh = function(self, event, target, player, data)
    data:changeDamage(1)
  end,
})

return congjian

